#单线程例子
def calculate_square(number):
    result = number * number
    print(f"Square of {number} is {result}")

def single_thread_example():
    numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    for number in numbers:
        calculate_square(number)

if __name__ == "__main__":
    single_thread_example()


#多线程例子
import threading

def calculate_square(number):
    result = number * number
    print(f"Square of {number} is {result}")

def multi_thread_example():
    numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    threads = []

    for number in numbers:
        thread = threading.Thread(target=calculate_square, args=(number,))
        threads.append(thread)
        thread.start()

    for thread in threads:
        thread.join()

if __name__ == "__main__":
    multi_thread_example()

